#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
constexpr int N(2e5+10),L(4e6+10);
namespace T
{
	int pool[N*2],*fa=pool,*siz=pool+N;
	std::pair<int,int> stk[L];int top,tot;
	void init(int n)
	{
		std::iota(fa+1,fa+n+1,1);
		std::fill(siz+1,siz+n+1,1);tot=n;
	}
	void merge(int u,int v)
	{
		// std::cerr<<"merge "<<u<<" "<<v<<std::endl;
		while(fa[u]!=u) u=fa[u];while(fa[v]!=v) v=fa[v];
		if(u==v) return;--tot;
		if(siz[u]<siz[v]) std::swap(u,v);stk[++top]={(fa-pool)+v,fa[v]};fa[v]=u;
		stk[++top]={(siz-pool)+u,siz[u]};siz[u]+=siz[v];
		// std::cerr<<"tot="<<tot<<std::endl;
	}
	void restore(int a,int b)
	{
		tot=b;while(top>a) pool[stk[top].first]=stk[top].second,--top;
	}
}
std::pair<int,int> es[N];int cnt[N],id[N*21];bool ans[N];
void solve(int l,int r)
{
	// std::cerr<<l<<" "<<r<<std::endl;
	if(l==r) return void(ans[l]=(T::tot==1));
	static int num[N];int mid((l+r)>>1),tstk(T::top),ttot(T::tot);
	for(int j(cnt[mid]+1);j<=cnt[r];++j) ++num[id[j]];
	for(int j(cnt[l-1]+1);j<=cnt[mid];++j) if(!num[id[j]])
	{
		auto [u,v]=es[id[j]];
		T::merge(u,v);
	}
	for(int j(cnt[mid]+1);j<=cnt[r];++j) num[id[j]]=0;
	solve(mid+1,r);T::restore(tstk,ttot);
	for(int j(cnt[l-1]+1);j<=cnt[mid];++j) ++num[id[j]];
	for(int j(cnt[mid]+1);j<=cnt[r];++j) if(!num[id[j]])
	{
		auto [u,v]=es[id[j]];
		T::merge(u,v);
	}
	for(int j(cnt[l-1]+1);j<=cnt[mid];++j) num[id[j]]=0;
	solve(l,mid);T::restore(tstk,ttot);
}
namespace fr
{
	#include <ctype.h>
	char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
	#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
	#define putchar(c) (((O==obuf+(1<<23))?(fwrite(obuf,1,O-obuf,stdout),O=obuf):O),*O++=(c))
	void rd(char *x){char c=getchar();while(isspace(c)) c=getchar();while(!isspace(c) && c!=EOF) *(x++)=c,c=getchar();*(x++)='\0';}
	template<class T> void rd(T &x){T ret=0;bool flg=false;char c=getchar();while(!isdigit(c) && c!='-') c=getchar();
		if(c=='-') c=getchar(),flg=true;while(isdigit(c)) ret=(ret<<1)+(ret<<3)+(c-'0'),c=getchar();if(flg) x=-ret;else x=ret;}
	void pc(char c){putchar(c);}void flush(){fwrite(obuf,1,O-obuf,stdout),O=obuf;}
	template<class T> void wr(T x){if(x<0) putchar('-'),x=-x;if(x==0) putchar('0');static int cnt,stk[110];cnt=0;while(x) stk[++cnt]=x%10,x/=10;for(int i=cnt;i;--i) putchar(stk[i]+'0');}
}
using fr::rd;using fr::pc;using fr::wr;using fr::flush;
int main()
{
	std::freopen("graph.in","r",stdin);
	std::freopen("graph.out","w",stdout);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);int n,m;/*std::cin>>n>>m;*/rd(n);rd(m);
	// std::cerr<<n<<" "<<m<<std::endl;
	static bool hv[N];T::init(n);
	for(int i(1),u,v;i<=m;++i)
	{
		rd(u);rd(v);es[i]={u,v};
	}
	int q;rd(q);
	for(int i(1);i<=q;++i)
	{
		rd(cnt[i]);cnt[i]+=cnt[i-1];
		for(int j(cnt[i-1]+1);j<=cnt[i];++j) rd(id[j]),hv[id[j]]=true;
	}
	for(int i(1);i<=m;++i) if(!hv[i])
	{
		auto [u,v]=es[i];T::merge(u,v);
	}
	solve(1,q);
	for(int i(1);i<=q;++i)
	{
		if(ans[i]) pc('Y'),pc('E'),pc('S');
		else pc('N'),pc('O');
		pc('\n');flush();
	}
	return 0;
}